<template>
  <div class="pageWrapper">
    <common-header />
    <div class="content">
      <div class="card">
        <div class="title">{{ content.taskName }}</div>
        <div class="time">{{ content.year }}年{{ content.startTime | timeFormat }} - {{ content.endTime | timeFormat }}</div>
      </div>
      <report-content :content="content" />
    </div>
  </div>
</template>

<script>
import reportContent from "../components/report-content.vue";
import { getReportDetailById, getMonthReportDetailById } from "@/api/report";
import { formatTime } from "@/utils";
export default {
  components: {
    reportContent
  },
  data() {
    return {
      id: 0,
      content: {},
      type: 1
    };
  },
  filters: {
    timeFormat(time) {
      return formatTime(time, "MM月dd日");
    }
  },
  created() {
    this.id = this.$route.query.id;
    this.type = this.$route.query.type;
    this.initData();
  },
  methods: {
    initData() {
      if (this.type == 1) {
        getReportDetailById(this.id).then(res => {
          this.content = res.data;
        });
      } else {
        getMonthReportDetailById(this.id).then(res => {
          this.content = res.data;
        });
      }
    }
  }
};
</script>

<style scoped lang="scss">
.content {
  padding: 20px 16px;
  .card {
    padding: 16px;
    background: #fff;
    border-radius: 8px;
    .title {
      line-height: 20px;
      color: #333;
      font-size: 14px;
    }
    .time {
      line-height: 17px;
      color: #a3a7ad;
      font-size: 12px;
      margin-top: 3px;
    }
  }
}
</style>
